<?php

namespace app\model;

use app\model\BaseModel;

/**
 * User模型
 */
class User extends BaseModel{
    protected function getOptions(): array{
        return [];
    }

    /**
     * 多对多 User-Role
     */
    public function roles(){
        return $this->belongsToMany(Role::class, 'user_role', 'role_id', 'user_id');
    }

    /**
     * 一对一 User-UserLoginLog
     */
    public function logs(){
        return $this->hasOne(UserLoginLog::class,'user_id','id');
    }
}